const Koa = require('koa');
const router = require('koa-router')();
const  koa_static = require("koa-static");
const bodyParser = require('koa-bodyparser');
const app = new Koa();

router.get('/', async (ctx,next)=>{
    ctx.response.body = '<h1>Index</h1>';
});
router.get('/api/test/:name',  async (ctx,next)=> {
    ctx.response.body = "12"+ctx.params.name;
});
router.post('/api/1',   async (ctx,next)=> {
    console.log(2);
    ctx.response.body = JSON.stringify(ctx.request.body);
});

app.use(bodyParser());
app.use(router.routes()).use(router.allowedMethods());
app.use(koa_static(__dirname+'/public'));
app.listen(3000);
console.log('app started at port 3000...');